package IU;

import Controladores.AnalizarContrato;
import Controladores.CtrlAMBOperario;
import Controladores.CtrlContrato;
import Controladores.CtrlEstadocontrato;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import utiles.Validador;

import Controladores.CtrlProducto;
import Controladores.CtrlProveedor;
import Controladores.CtrlDetallecontrato;

import Entidades.Estadocontrato;
import Entidades.Proveedor;
import Entidades.Producto;
import Entidades.Contrato;
import Entidades.Operario;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import Entidades.Detallecontrato;
import com.mysql.jdbc.Connection;
import java.io.InputStream;
import java.sql.DriverManager;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Iterator;
import javax.swing.table.DefaultTableModel;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.view.JasperViewer;

/**
 *
 * @author  
 * 
 * 
 */
public class ABMContrato extends javax.swing.JFrame {

    private String fechaAlta;
    String telefono1;
    String telefono2;
    Proveedor proveedor;
    TablaPersonalizada tableModel;
    private List listap;
    CtrlProveedor controladorprovee;
    CtrlProducto controladorproducto;
    CtrlContrato controladorcontrato;
    CtrlEstadocontrato controladorestadocontrato;
    CtrlDetallecontrato controladordetallecontrato;
    CtrlAMBOperario controladoroperario;
    Producto producto;
    Validador validador;
    private List listao;
    Estadocontrato estadocontrato = null;
    Contrato contrato = new Contrato();
    Operario o;
    String observaciones = null;
    private List lista, listad;
    List<Detallecontrato> listasDetalle = new ArrayList<Detallecontrato>();
    private String cantidad;
    float cant;
    private String precio;
    float prec;
    int cuart;
    String cuartel;
    String pro;
    Detallecontrato de;
    private Proveedor list;
    private String fecha;
    String op;
    private List<Contrato> listContrato;
    private List<Detallecontrato> ListaDetalle;
    private List<Contrato> listContratoe;
    AnalizarContrato ac = new AnalizarContrato();
    private List<Detallecontrato> listaDetalles;
    private List<Detallecontrato> listaDetalle;

    public ABMContrato(String operario) {
        initComponents();
        op = operario;

        jTextFieldUsuario3.setText(op);
        //      jTextFieldUsuario4.setText(op);
        controladorprovee = new CtrlProveedor();
        controladorproducto = new CtrlProducto();
        controladorcontrato = new CtrlContrato();
        controladordetallecontrato = new CtrlDetallecontrato();
        controladorestadocontrato = new CtrlEstadocontrato();
        controladoroperario = new CtrlAMBOperario();


        cargarComboRazon();
        cargarComboRazon1();
        cargarComboRazon2();
        //       CargarTabla();

        cargarComboNomProducto();
        jButtonAgregar.setEnabled(false);
        jButtonGuardar.setEnabled(false);
        jButtonBuscarProductoContrato.setEnabled(false);
        try {
            o = controladoroperario.buscarOperarioApellido(op);

        } catch (Exception ex) {
            Logger.getLogger(ABMContrato.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        GestorPesajeJpaPU2EntityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("GestorPesajeJpaPU2").createEntityManager();
        proveedorQuery = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT p FROM Proveedor p");
        proveedorList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : proveedorQuery.getResultList();
        contratoQuery = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT c FROM Contrato c");
        contratoList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : contratoQuery.getResultList();
        estadocontratoQuery = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT e FROM Estadocontrato e");
        estadocontratoList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : estadocontratoQuery.getResultList();
        estadocontratoQuery1 = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT e.nombre FROM Estadocontrato e");
        estadocontratoList1 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : estadocontratoQuery1.getResultList();
        estadocontratoQuery2 = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT e FROM Estadocontrato e");
        estadocontratoList2 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : estadocontratoQuery2.getResultList();
        contratoQuery2 = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT c FROM Contrato c");
        contratoList2 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : contratoQuery2.getResultList();
        estadocontratoQuery3 = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT e FROM Estadocontrato e");
        estadocontratoList3 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : estadocontratoQuery3.getResultList();
        estadocontratoQuery4 = java.beans.Beans.isDesignTime() ? null : GestorPesajeJpaPU2EntityManager.createQuery("SELECT e.nombre FROM Estadocontrato e");
        estadocontratoList4 = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : estadocontratoQuery4.getResultList();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabelDireccionCon = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTextAreaObserv = new javax.swing.JTextArea();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTableDetallesConsulta = new javax.swing.JTable();
        jScrollPane10 = new javax.swing.JScrollPane();
        jScrollPane5 = new javax.swing.JScrollPane();
        jTableContratos = new javax.swing.JTable();
        jPanel15 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jComboBoxprov2 = new javax.swing.JComboBox();
        Buscar2 = new javax.swing.JButton();
        jPanel10 = new javax.swing.JPanel();
        jPanel11 = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        jTableDetallesConsulta1 = new javax.swing.JTable();
        jScrollPane11 = new javax.swing.JScrollPane();
        jScrollPane9 = new javax.swing.JScrollPane();
        jTableContratos1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        jTextAreaObserv1 = new javax.swing.JTextArea();
        jLabelDireccionCon1 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldCantidad = new javax.swing.JTextField();
        jTextFieldCuartel = new javax.swing.JTextField();
        jDateChooserSelectorFecha1 = new com.toedter.calendar.JDateChooser();
        jLabel19 = new javax.swing.JLabel();
        jComboBoxEstado = new javax.swing.JComboBox();
        jPanel13 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jComboBoxprov = new javax.swing.JComboBox();
        Buscar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jComboBoxRazonContrato = new javax.swing.JComboBox();
        jTextFieldapellido = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTextFielCuit1 = new javax.swing.JTextField();
        jLabelTelCon2 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldnombre = new javax.swing.JTextField();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaObservaciones = new javax.swing.JTextArea();
        jPanel7 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldCantidadAlta = new javax.swing.JTextField();
        jPanel8 = new javax.swing.JPanel();
        jTextFielpreciolistar = new javax.swing.JTextField();
        jTextFieldclasiflistar = new javax.swing.JTextField();
        jTextFielddescripcionlistar = new javax.swing.JTextField();
        jComboBoxNombreProd = new javax.swing.JComboBox();
        jLabel30 = new javax.swing.JLabel();
        jLabelDniCon1 = new javax.swing.JLabel();
        jLabelApellidoCon1 = new javax.swing.JLabel();
        jLabelTelCon1 = new javax.swing.JLabel();
        jButtonBuscarProductoContrato = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldcuartel = new javax.swing.JTextField();
        jPanel9 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableDetalle = new javax.swing.JTable();
        jButtonGuardar = new javax.swing.JButton();
        jButtonAgregar = new javax.swing.JButton();
        jButtonBuscarProveedorContrato = new javax.swing.JButton();
        jPanel17 = new javax.swing.JPanel();
        jPanel19 = new javax.swing.JPanel();
        Buscar4 = new javax.swing.JButton();
        jLabel15 = new javax.swing.JLabel();
        jComboBoxestadocontrato = new javax.swing.JComboBox();
        jPanel20 = new javax.swing.JPanel();
        jScrollPane13 = new javax.swing.JScrollPane();
        jScrollPane12 = new javax.swing.JScrollPane();
        jTableContratosEstados = new javax.swing.JTable();
        jPanel21 = new javax.swing.JPanel();
        jScrollPane14 = new javax.swing.JScrollPane();
        jScrollPane15 = new javax.swing.JScrollPane();
        jTableDetallesConsultaEstado = new javax.swing.JTable();
        jPanel22 = new javax.swing.JPanel();
        jScrollPane16 = new javax.swing.JScrollPane();
        jTextAreaObservacionesEstados = new javax.swing.JTextArea();
        jButton2 = new javax.swing.JButton();
        jButtonSalir = new javax.swing.JButton();
        jPanel16 = new javax.swing.JPanel();
        jTextFieldUsuario3 = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Alta de Contrato - Sistema Gestor de Pesaje para Bodegas");

        jTabbedPane1.setForeground(new java.awt.Color(102, 0, 102));
        jTabbedPane1.setFont(new java.awt.Font("Segoe UI", 3, 12));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Buscar contrato ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jLabelDireccionCon.setFont(new java.awt.Font("Segoe UI", 3, 11));
        jLabelDireccionCon.setForeground(new java.awt.Color(102, 0, 102));
        jLabelDireccionCon.setText("Observaciones:");

        jTextAreaObserv.setColumns(20);
        jTextAreaObserv.setEditable(false);
        jTextAreaObserv.setRows(5);
        jTextAreaObserv.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jScrollPane6.setViewportView(jTextAreaObserv);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Detalle ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jTableDetallesConsulta.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jTableDetallesConsulta.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jTableDetallesConsulta.setForeground(new java.awt.Color(102, 0, 102));
        jTableDetallesConsulta.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Producto", "Cantidad", "Cuartel", "Precio", "Estado "
            }
        ));
        jTableDetallesConsulta.setAutoscrolls(false);
        jTableDetallesConsulta.setFillsViewportHeight(true);
        jTableDetallesConsulta.setMinimumSize(new java.awt.Dimension(55, 55));
        jTableDetallesConsulta.setPreferredSize(new java.awt.Dimension(200, 42));
        jTableDetallesConsulta.setRowHeight(14);
        jTableDetallesConsulta.getTableHeader().setResizingAllowed(false);
        jScrollPane3.setViewportView(jTableDetallesConsulta);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTableContratos.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTableContratos.getTableHeader().setReorderingAllowed(false);
        jTableContratos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableContratosMouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(jTableContratos);

        jScrollPane10.setViewportView(jScrollPane5);

        jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Busqueda por Proveedor", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jLabel11.setFont(new java.awt.Font("Segoe UI", 3, 11));
        jLabel11.setText("Proveedor:");

        jComboBoxprov2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        Buscar2.setFont(new java.awt.Font("Segoe UI", 3, 12));
        Buscar2.setForeground(new java.awt.Color(102, 0, 102));
        Buscar2.setText("Buscar");
        Buscar2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Buscar2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel15Layout.createSequentialGroup()
                .addContainerGap(102, Short.MAX_VALUE)
                .addComponent(jLabel11)
                .addGap(18, 18, 18)
                .addComponent(jComboBoxprov2, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(64, 64, 64)
                .addComponent(Buscar2)
                .addGap(89, 89, 89))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jComboBoxprov2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Buscar2))
                .addContainerGap(58, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jPanel15, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jScrollPane10, javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                            .addComponent(jLabelDireccionCon)
                            .addGap(18, 18, 18)
                            .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 467, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelDireccionCon)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(45, 45, 45))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(377, 377, 377))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Listar Contratos", jPanel3);

        jPanel10.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Modificar Contrato ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Detalle ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTableDetallesConsulta1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTableDetallesConsulta1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Producto", "Cantidad", "Cuartel", "Precio", "Estado"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, true, true, true, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableDetallesConsulta1.setAutoscrolls(false);
        jTableDetallesConsulta1.setFillsViewportHeight(true);
        jTableDetallesConsulta1.setMinimumSize(new java.awt.Dimension(55, 55));
        jTableDetallesConsulta1.setPreferredSize(new java.awt.Dimension(200, 42));
        jTableDetallesConsulta1.setRowHeight(14);
        jTableDetallesConsulta1.getTableHeader().setResizingAllowed(false);
        jScrollPane8.setViewportView(jTableDetallesConsulta1);

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTableContratos1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTableContratos1.getTableHeader().setReorderingAllowed(false);

        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, contratoList2, jTableContratos1);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        jTableContratos1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableContratos1MouseClicked(evt);
            }
        });
        jScrollPane9.setViewportView(jTableContratos1);

        jScrollPane11.setViewportView(jScrollPane9);

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE)
                    .addComponent(jPanel12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(92, 92, 92))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
        );

        jButton1.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButton1.setForeground(new java.awt.Color(102, 0, 102));
        jButton1.setText("Modificar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel1.setText("Cantidad:");

        jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel3.setText("Cuartel:");

        jTextAreaObserv1.setColumns(20);
        jTextAreaObserv1.setRows(5);
        jTextAreaObserv1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jScrollPane7.setViewportView(jTextAreaObserv1);

        jLabelDireccionCon1.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelDireccionCon1.setText("Observaciones:");

        jLabel7.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel7.setText("Estado:");

        jTextFieldCantidad.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldCuartel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTextFieldCuartel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCuartelActionPerformed(evt);
            }
        });

        jLabel19.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel19.setText("Fecha:");

        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, estadocontratoList1, jComboBoxEstado);
        bindingGroup.addBinding(jComboBoxBinding);

        jComboBoxEstado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxEstadoActionPerformed(evt);
            }
        });

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Seleccione Proveedor:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jLabel9.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel9.setText("Proveedor:");

        jComboBoxprov.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, proveedorList, org.jdesktop.beansbinding.ObjectProperty.create(), jComboBoxprov, org.jdesktop.beansbinding.BeanProperty.create("selectedItem"));
        bindingGroup.addBinding(binding);

        Buscar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        Buscar.setForeground(new java.awt.Color(102, 0, 102));
        Buscar.setText("Buscar");
        Buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BuscarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBoxprov, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(Buscar, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                .addContainerGap(25, Short.MAX_VALUE)
                .addGroup(jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxprov, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(37, 37, 37)
                .addComponent(Buscar)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel1))
                        .addGap(308, 308, 308)
                        .addComponent(jLabel7))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addComponent(jLabelDireccionCon1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                                        .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE)
                                        .addGap(38, 38, 38)
                                        .addComponent(jButton1))
                                    .addGroup(jPanel10Layout.createSequentialGroup()
                                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(jTextFieldCuartel, javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jTextFieldCantidad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE))
                                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addGroup(jPanel10Layout.createSequentialGroup()
                                                .addGap(72, 72, 72)
                                                .addComponent(jLabel19)
                                                .addGap(18, 18, 18)
                                                .addComponent(jDateChooserSelectorFecha1, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel10Layout.createSequentialGroup()
                                                .addGap(123, 123, 123)
                                                .addComponent(jComboBoxEstado, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))))
                            .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)))
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(37, 37, 37)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jLabel7)
                            .addComponent(jTextFieldCantidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBoxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(38, 38, 38)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel3)
                                .addComponent(jTextFieldCuartel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel19))
                            .addComponent(jDateChooserSelectorFecha1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(21, 21, 21)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel10Layout.createSequentialGroup()
                                    .addGap(18, 18, 18)
                                    .addComponent(jLabelDireccionCon1))
                                .addComponent(jScrollPane7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jButton1))))
                .addContainerGap(125, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Modificar Contrato", jPanel10);

        jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Seleccionar Proveedor", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jComboBoxRazonContrato.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jComboBoxRazonContratoMousePressed(evt);
            }
        });
        jComboBoxRazonContrato.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxRazonContratoActionPerformed(evt);
            }
        });

        jTextFieldapellido.setEditable(false);
        jTextFieldapellido.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jLabel12.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel12.setText("Razón Social:");

        jLabel4.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel4.setText("Apellido:");

        jTextFielCuit1.setEditable(false);
        jTextFielCuit1.setFont(new java.awt.Font("Segoe UI", 1, 11));

        jLabelTelCon2.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelTelCon2.setText("Cuit:");

        jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel2.setText("Nombre:");

        jTextFieldnombre.setEditable(false);
        jTextFieldnombre.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(95, 95, 95)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel12)
                            .addComponent(jLabelTelCon2)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jTextFielCuit1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBoxRazonContrato, javax.swing.GroupLayout.Alignment.LEADING, 0, 300, Short.MAX_VALUE)
                            .addComponent(jTextFieldnombre, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
                            .addComponent(jTextFieldapellido, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 326, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(146, 146, 146))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxRazonContrato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jTextFieldapellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(9, 9, 9)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextFieldnombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFielCuit1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelTelCon2))
                .addContainerGap(25, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Observaciones:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102)), "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(0, 102, 153))); // NOI18N

        jTextAreaObservaciones.setColumns(20);
        jTextAreaObservaciones.setRows(5);
        jTextAreaObservaciones.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jScrollPane1.setViewportView(jTextAreaObservaciones);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 566, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(39, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Detalle ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jLabel5.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel5.setText("Cantidad:");

        jTextFieldCantidadAlta.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Seleccionar Producto:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jTextFielpreciolistar.setEditable(false);
        jTextFielpreciolistar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFieldclasiflistar.setEditable(false);
        jTextFieldclasiflistar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jTextFielddescripcionlistar.setEditable(false);
        jTextFielddescripcionlistar.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        jComboBoxNombreProd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxNombreProdActionPerformed(evt);
            }
        });

        jLabel30.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel30.setText("Descripción:");

        jLabelDniCon1.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelDniCon1.setText("Clasificación:");

        jLabelApellidoCon1.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelApellidoCon1.setText("Nombre:");

        jLabelTelCon1.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabelTelCon1.setText("Precio:");

        jButtonBuscarProductoContrato.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonBuscarProductoContrato.setForeground(new java.awt.Color(102, 0, 102));
        jButtonBuscarProductoContrato.setMnemonic('B');
        jButtonBuscarProductoContrato.setText("Buscar");
        jButtonBuscarProductoContrato.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarProductoContratoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelApellidoCon1)
                    .addComponent(jLabelDniCon1)
                    .addComponent(jLabel30))
                .addGap(10, 10, 10)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jComboBoxNombreProd, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(48, 48, 48)
                        .addComponent(jButtonBuscarProductoContrato))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(jTextFieldclasiflistar, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabelTelCon1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFielpreciolistar, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jTextFielddescripcionlistar, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(47, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelApellidoCon1)
                    .addComponent(jButtonBuscarProductoContrato)
                    .addComponent(jComboBoxNombreProd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFielddescripcionlistar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel30))
                .addGap(6, 6, 6)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldclasiflistar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDniCon1)
                    .addComponent(jLabelTelCon1)
                    .addComponent(jTextFielpreciolistar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jLabel8.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel8.setText("Kilogramos.");

        jLabel6.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jLabel6.setText("Cuartel:");

        jTextFieldcuartel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jLabel6)
                        .addGap(35, 35, 35)
                        .addComponent(jTextFieldcuartel, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(34, 34, 34)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldCantidadAlta, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel8))
                    .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldcuartel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel5)
                    .addComponent(jTextFieldCantidadAlta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Datos del contrato", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N

        jTableDetalle.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        jTableDetalle.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Producto", "Clasificación", "Cantidad", "Precio", "SubTotal"
            }
        ));
        jTableDetalle.setAutoscrolls(false);
        jTableDetalle.setFillsViewportHeight(true);
        jTableDetalle.setMinimumSize(new java.awt.Dimension(55, 55));
        jTableDetalle.setPreferredSize(new java.awt.Dimension(200, 42));
        jTableDetalle.setRowHeight(14);
        jTableDetalle.getTableHeader().setResizingAllowed(false);
        jScrollPane2.setViewportView(jTableDetalle);

        jScrollPane4.setViewportView(jScrollPane2);

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap(31, Short.MAX_VALUE)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 572, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonGuardar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonGuardar.setForeground(new java.awt.Color(102, 0, 102));
        jButtonGuardar.setText("Guardar");
        jButtonGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGuardarActionPerformed(evt);
            }
        });

        jButtonAgregar.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonAgregar.setForeground(new java.awt.Color(102, 0, 102));
        jButtonAgregar.setText("Agregar");
        jButtonAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAgregarActionPerformed(evt);
            }
        });

        jButtonBuscarProveedorContrato.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonBuscarProveedorContrato.setForeground(new java.awt.Color(102, 0, 102));
        jButtonBuscarProveedorContrato.setMnemonic('B');
        jButtonBuscarProveedorContrato.setText("Buscar");
        jButtonBuscarProveedorContrato.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarProveedorContratoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(184, 184, 184)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(29, 29, 29)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonBuscarProveedorContrato)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(jButtonGuardar)
                        .addComponent(jButtonAgregar)))
                .addContainerGap(111, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonBuscarProveedorContrato)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonAgregar)
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(68, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonGuardar)
                        .addGap(42, 42, 42))))
        );

        jTabbedPane1.addTab("Alta Contrato", jPanel1);

        jPanel19.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), " Estado Contrato", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        Buscar4.setFont(new java.awt.Font("Segoe UI", 3, 12));
        Buscar4.setForeground(new java.awt.Color(102, 0, 102));
        Buscar4.setText("Buscar");
        Buscar4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Buscar4ActionPerformed(evt);
            }
        });

        jLabel15.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jLabel15.setText("Estado:");

        jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings.createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, estadocontratoList4, jComboBoxestadocontrato);
        bindingGroup.addBinding(jComboBoxBinding);

        javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19);
        jPanel19.setLayout(jPanel19Layout);
        jPanel19Layout.setHorizontalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel19Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(Buscar4)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel19Layout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addGap(30, 30, 30)
                        .addComponent(jComboBoxestadocontrato, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18))
        );
        jPanel19Layout.setVerticalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel19Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jComboBoxestadocontrato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Buscar4)
                .addGap(23, 23, 23))
        );

        jPanel20.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Contratos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTableContratosEstados.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Numero", "Fecha", "Operario", "Proveedor"
            }
        ));
        jTableContratosEstados.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTableContratosEstadosMouseClicked(evt);
            }
        });
        jScrollPane12.setViewportView(jTableContratosEstados);

        jScrollPane13.setViewportView(jScrollPane12);

        jPanel21.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Detalle del Contrato", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTableDetallesConsultaEstado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Producto", "Cantidad", "Cuartel", "Precio", "Estado", "Cantidad Recibida"
            }
        ));
        jScrollPane15.setViewportView(jTableDetallesConsultaEstado);

        jScrollPane14.setViewportView(jScrollPane15);

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jScrollPane14, javax.swing.GroupLayout.DEFAULT_SIZE, 797, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane14, javax.swing.GroupLayout.DEFAULT_SIZE, 184, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel20Layout = new javax.swing.GroupLayout(jPanel20);
        jPanel20.setLayout(jPanel20Layout);
        jPanel20Layout.setHorizontalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addGroup(jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 817, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel20Layout.setVerticalGroup(
            jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel20Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(19, Short.MAX_VALUE))
        );

        jPanel22.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Observaciones del Contrato:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 12), new java.awt.Color(102, 0, 102))); // NOI18N

        jTextAreaObservacionesEstados.setColumns(20);
        jTextAreaObservacionesEstados.setEditable(false);
        jTextAreaObservacionesEstados.setRows(5);
        jScrollPane16.setViewportView(jTextAreaObservacionesEstados);

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addComponent(jScrollPane16, javax.swing.GroupLayout.PREFERRED_SIZE, 433, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane16, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton2.setText("Reporte Contrato");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(99, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel17Layout.createSequentialGroup()
                .addContainerGap(689, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addGap(270, 270, 270))
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18))
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)))
                .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2)
                .addContainerGap(56, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Consultar Contratos por Estado", jPanel17);

        jButtonSalir.setFont(new java.awt.Font("Segoe UI", 3, 12));
        jButtonSalir.setForeground(new java.awt.Color(102, 0, 102));
        jButtonSalir.setText("Salir");
        jButtonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalirActionPerformed(evt);
            }
        });

        jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED), "Usuario Registrado", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 3, 11), new java.awt.Color(102, 0, 102))); // NOI18N
        jPanel16.setForeground(new java.awt.Color(102, 0, 102));

        jTextFieldUsuario3.setEditable(false);
        jTextFieldUsuario3.setFont(new java.awt.Font("Segoe UI", 1, 11));
        jTextFieldUsuario3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario3, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextFieldUsuario3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1037, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonSalir))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane1))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(32, 32, 32)
                        .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 572, Short.MAX_VALUE)
                        .addComponent(jButtonSalir)
                        .addGap(12, 12, 12)))
                .addGap(44, 44, 44))
        );

        bindingGroup.bind();

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1287)/2, (screenSize.height-760)/2, 1287, 760);
    }// </editor-fold>//GEN-END:initComponents

    private void refresh() {
        jTextFieldapellido.setText("");

    }

private void jButtonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalirActionPerformed
    this.dispose();
}//GEN-LAST:event_jButtonSalirActionPerformed

private void jButtonBuscarProveedorContratoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarProveedorContratoActionPerformed

    jButtonBuscarProductoContrato.setEnabled(true);
    System.out.println("");
    Proveedor miprov = null;
    Object esteoperar = jComboBoxRazonContrato.getSelectedItem();
    String nombrecuil = esteoperar.toString();
    System.out.println("nombre cuil " + nombrecuil);
    try {
        miprov = controladorprovee.buscarProveedorRazon(nombrecuil);
        System.out.println("mioperar " + miprov);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "El proveedor ingresado no se ha encontrado.\n ", "Proveedor", JOptionPane.ERROR_MESSAGE);
    }

    if (miprov != null) {

        jTextFieldnombre.setText(miprov.getNombreProveedor());
        jTextFielCuit1.setText(String.valueOf(miprov.getCuitProveedor()));
        jTextFieldapellido.setText(miprov.getApellidoProveedor());
    }
}//GEN-LAST:event_jButtonBuscarProveedorContratoActionPerformed

private void jButtonAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAgregarActionPerformed

    jButtonBuscarProveedorContrato.setEnabled(false);

    String nomproveed = jComboBoxRazonContrato.getSelectedItem().toString();
    try {
        proveedor = controladorprovee.buscarProveedorRazon(nomproveed);

    } catch (Exception e) {
    }


    fechaAlta = Validador.getInstance().obtenerFechaSistema();
    System.out.println("La fecha de hoy es: " + fechaAlta);


    observaciones = jTextAreaObservaciones.getText();
    try {
        estadocontrato = controladorestadocontrato.buscarEstadocontratoNombre("pendiente");
        System.out.println(estadocontrato);
    } catch (Exception e) {
        System.out.println(e);
    }


    cuartel = jTextFieldcuartel.getText();
    cantidad = jTextFieldCantidadAlta.getText();
    pro = jComboBoxNombreProd.getSelectedItem().toString();

    cant = Float.parseFloat(cantidad);
    cuart = Integer.parseInt(cuartel);

    prec = producto.getPrecio();

    System.out.println("boton agregar antes de verificar");
    if (verificar(cantidad, cuart, pro)) { //verifica que los datos ingresados tengan el formato correcto

        jButtonGuardar.setEnabled(true);

        de = new Detallecontrato();//

        de.setProducto(producto);
        de.setCantidad(Float.parseFloat(cantidad));
        de.setPrecio(producto.getPrecio());
        de.setCuartel(Integer.parseInt(cuartel));
        de.setEstadocontrato(estadocontrato);


        System.out.println("boton agregar antes de llamar alcontrolador para que guarde el detalle");

        System.out.println("boton agregar ddespues de guardar detalle");

        listasDetalle.add(de);
        mostrarGrilla();

        jTextFieldcuartel.setText("");
        jTextFieldCantidadAlta.setText("");
    }
}//GEN-LAST:event_jButtonAgregarActionPerformed

private void jButtonGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGuardarActionPerformed

    List<Detallecontrato> detGuardar = new ArrayList<Detallecontrato>();
    try {
    } catch (Exception ex) {
        Logger.getLogger(ABMContrato.class.getName()).log(Level.SEVERE, null, ex);
    }


    contrato.setFechaHoraContrato(fechaAlta);
    contrato.setProveedor(proveedor);
    contrato.setOperario(o);
    contrato.setObservaciones(observaciones);
    contrato.setEstadocontrato(estadocontrato);
    controladorcontrato.guardarContrato(contrato);

    for (Iterator it = listasDetalle.iterator(); it.hasNext();) {
        Detallecontrato detalle = (Detallecontrato) it.next();
        detalle.setContrato(contrato);
        controladordetallecontrato.guardarDetallecontrato(detalle);

    }



    JOptionPane.showMessageDialog(this, "Contrato dado de Alta Pendiente", "Contrato", JOptionPane.INFORMATION_MESSAGE);
    CargarTabla();
    CargarTabla1();
    limpiarAlta();

}//GEN-LAST:event_jButtonGuardarActionPerformed

private void jButtonBuscarProductoContratoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarProductoContratoActionPerformed

    jButtonBuscarProveedorContrato.setEnabled(false);


    System.out.println("");

    Object esteoperar = jComboBoxNombreProd.getSelectedItem();
    String nombrepro = esteoperar.toString();
    System.out.println("nombre producto " + nombrepro);
    try {
        producto = controladorproducto.buscarProductoNombre(nombrepro);
        System.out.println("producto:  " + producto);
        jButtonAgregar.setEnabled(true);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, "El producto ingresado no se ha encontrado.\n ", "Productos", JOptionPane.ERROR_MESSAGE);
    }
    if (producto != null) {

        jTextFielddescripcionlistar.setText(producto.getDescripcionProducto());
        jTextFieldclasiflistar.setText(producto.getClasificacionproducto().getNombreclasificacion());
        jTextFielpreciolistar.setText(String.valueOf(producto.getPrecio()));
    }
}//GEN-LAST:event_jButtonBuscarProductoContratoActionPerformed

private void jComboBoxNombreProdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxNombreProdActionPerformed
}//GEN-LAST:event_jComboBoxNombreProdActionPerformed

private void jComboBoxRazonContratoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxRazonContratoActionPerformed
}//GEN-LAST:event_jComboBoxRazonContratoActionPerformed

private void jComboBoxRazonContratoMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jComboBoxRazonContratoMousePressed
    limpiarDatos();        // TODO add your handling code here:
}//GEN-LAST:event_jComboBoxRazonContratoMousePressed

private void BuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BuscarActionPerformed
    CargarContratosPorProveedor();        // TODO add your handling code here:
}//GEN-LAST:event_BuscarActionPerformed

private void jComboBoxEstadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxEstadoActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jComboBoxEstadoActionPerformed

private void jTextFieldCuartelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCuartelActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jTextFieldCuartelActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    modificarContrato();        // TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed

private void jTableContratos1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableContratos1MouseClicked
    CargarDetallePorContrato();        // TODO add your handling code here:
}//GEN-LAST:event_jTableContratos1MouseClicked

private void Buscar2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Buscar2ActionPerformed
    CargarContratosPorProveedor1();   // TODO add your handling code here:
}//GEN-LAST:event_Buscar2ActionPerformed

private void jTableContratosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableContratosMouseClicked
    CargarDetallePorContrato1();        // TODO add your handling code here:
}//GEN-LAST:event_jTableContratosMouseClicked

private void Buscar4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Buscar4ActionPerformed
    CargarContratosPorEstados();    // TODO add your handling code here:
}//GEN-LAST:event_Buscar4ActionPerformed

private void jTableContratosEstadosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTableContratosEstadosMouseClicked
    CargarDetallePorContratoEstado();    // TODO add your handling code here:
}//GEN-LAST:event_jTableContratosEstadosMouseClicked

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
int ind =jTableDetallesConsultaEstado.getSelectedRow();
float ca= 0;
        try {
            ca = ac.calcularCantidadPendiente((Detallecontrato) ListaDetalle.get(ind));
        } catch (Exception ex) {
            Logger.getLogger(ABMContrato.class.getName()).log(Level.SEVERE, null, ex);
        }
Detallecontrato detco= (Detallecontrato) ListaDetalle.get(ind);
System.out.println(detco.getIdDetalleContrato()+ "cantidad "+ca );
    crearReportes("Reportes/ContratoCantidadRecibida.jasper",detco.getIdDetalleContrato().toString(),String.valueOf(ca));
//    crearReportes("Reportes/ContratoCantidadRecibida.jasper");
    //por cada uno de los detalles de contrato, debería pasar la cantidad recibida    // TODO add your handling code here:
}//GEN-LAST:event_jButton2ActionPerformed

    public void actualizarDatos(Proveedor proveedorSel) {
    }

    private void CargarTabla() {
        String[] encabezados = new String[4];
        encabezados[0] = "Numero";
        encabezados[1] = "Proveedor";
        encabezados[2] = "Fecha";
        encabezados[3] = "Estado";


        tableModel = new TablaPersonalizada(encabezados);
        jTableContratos.setModel(tableModel);

        try {
            listContrato = controladorcontrato.buscarTodosContrato();
            System.out.println("tamaño de listao" + lista.size());

            for (int i = 0; i < listContrato.size(); i++) {
                Vector fila = new Vector();
                Contrato contrato = (Contrato) listContrato.get(i);
                fila.add(contrato.getNumeroContrato());
                fila.add(contrato.getProveedor().getRazonSocialProveedor());
                fila.add(contrato.getFechaHoraContrato());
                fila.add(contrato.getEstadocontrato().getNombre());


                tableModel.addRow(fila);
            }
        } catch (Exception e) {
        }
    }

    private void limpiarCampos() {
    }

    private void cargarComboRazon1() {
        try {
            listap = controladorprovee.buscarTodosProveedor();
            System.out.println("tamaño de la lista de proveedores " + listap.size());

        } catch (Exception e) {
        }
        jComboBoxprov.removeAllItems();
        for (int i = 0; i < listap.size(); i++) {
            Vector fila = new Vector();
            Proveedor prove = (Proveedor) listap.get(i);
            fila.add(prove.getRazonSocialProveedor());
            jComboBoxprov.addItem(fila.get(0));
        }
    }

    private void cargarComboRazon() {
        try {
            listap = controladorprovee.buscarTodosProveedor();
            System.out.println("tamaño de la lista de proveedores " + listap.size());

        } catch (Exception e) {
        }
        jComboBoxRazonContrato.removeAllItems();
        for (int i = 0; i < listap.size(); i++) {
            Vector fila = new Vector();
            Proveedor prove = (Proveedor) listap.get(i);
            fila.add(prove.getRazonSocialProveedor());
            jComboBoxRazonContrato.addItem(fila.get(0));
        }
    }

    public void mostrarGrilla() {
        String columnas[] = {"Producto", "Clasificacion", "Cantidad", "Precio", "SubTotal"};
        DefaultTableModel dtmDetalle = new DefaultTableModel(columnas, 0);
        jTableDetalle.setModel(dtmDetalle);


        for (Iterator it = listasDetalle.iterator(); it.hasNext();) {
            Detallecontrato det = (Detallecontrato) it.next();


            String[] fila = {det.getProducto().getNombreProducto(),
                det.getProducto().getClasificacionproducto().getNombreclasificacion(),
                String.valueOf(det.getCantidad()),
                String.valueOf(det.getPrecio()),
                String.valueOf(det.getPrecio() * det.getCantidad())};

            dtmDetalle.addRow(fila);
        }
    }//////////////////LISTAR///////////////

    private boolean verificar(String razon, String nroPrevSocial, String apellido, String nombre, String nroIB, String nroInv, String pais, String provincia, String localidad, String telefono1, String telefono2, String direccion) {

        boolean ver = false;
        if (razon.equals("") || nroPrevSocial.equals("") || apellido.equals("") || nombre.equals("") || nroIB.equals("") || nroInv.equals("") || pais.equals("") || provincia.equals("") || localidad.equals("") || telefono1.equals("") || telefono2.equals("") || direccion.equals("")) {
            JOptionPane.showMessageDialog(this, "Por favor llene todos los campos!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!Validador.getInstance().soloContieneLetrasYNumerosYEspacios(razon)) {
            JOptionPane.showMessageDialog(this, "Apellido invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneLetrasYEspacios(apellido)) {
            JOptionPane.showMessageDialog(this, "Nombre invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneLetrasYEspacios(nombre)) {
            JOptionPane.showMessageDialog(this, "Nombre invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneNumerosYGuiones(nroIB)) {
            JOptionPane.showMessageDialog(this, "Número de Ingresos Brutos invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().soloContieneNumerosYGuiones(nroInv)) {
            JOptionPane.showMessageDialog(this, "Número de Ingresos Brutos invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);


        } else if (!validador.getInstance().soloContieneLetrasYNumerosYEspacios(direccion)) {

            JOptionPane.showMessageDialog(this, "Dirección invalido!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().esTelefonoValido(telefono1)) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para telefono1 es incorrecto!!!", "Error", JOptionPane.ERROR_MESSAGE);

        } else if (!validador.getInstance().esTelefonoValido(telefono2)) {
            JOptionPane.showMessageDialog(this, "El valor ingresado para telefono2 es incorrecto!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            ver = true;
        }
        return ver;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Buscar;
    private javax.swing.JButton Buscar2;
    private javax.swing.JButton Buscar4;
    private javax.persistence.EntityManager GestorPesajeJpaPU2EntityManager;
    private java.util.List<Entidades.Contrato> contratoList;
    private java.util.List<Entidades.Contrato> contratoList2;
    private javax.persistence.Query contratoQuery;
    private javax.persistence.Query contratoQuery2;
    private java.util.List<Entidades.Estadocontrato> estadocontratoList;
    private java.util.List<Entidades.Estadocontrato> estadocontratoList1;
    private java.util.List<Entidades.Estadocontrato> estadocontratoList2;
    private java.util.List<Entidades.Estadocontrato> estadocontratoList3;
    private java.util.List<Entidades.Estadocontrato> estadocontratoList4;
    private javax.persistence.Query estadocontratoQuery;
    private javax.persistence.Query estadocontratoQuery1;
    private javax.persistence.Query estadocontratoQuery2;
    private javax.persistence.Query estadocontratoQuery3;
    private javax.persistence.Query estadocontratoQuery4;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButtonAgregar;
    private javax.swing.JButton jButtonBuscarProductoContrato;
    private javax.swing.JButton jButtonBuscarProveedorContrato;
    private javax.swing.JButton jButtonGuardar;
    private javax.swing.JButton jButtonSalir;
    private javax.swing.JComboBox jComboBoxEstado;
    private javax.swing.JComboBox jComboBoxNombreProd;
    private javax.swing.JComboBox jComboBoxRazonContrato;
    private javax.swing.JComboBox jComboBoxestadocontrato;
    private javax.swing.JComboBox jComboBoxprov;
    private javax.swing.JComboBox jComboBoxprov2;
    private com.toedter.calendar.JDateChooser jDateChooserSelectorFecha1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelApellidoCon1;
    private javax.swing.JLabel jLabelDireccionCon;
    private javax.swing.JLabel jLabelDireccionCon1;
    private javax.swing.JLabel jLabelDniCon1;
    private javax.swing.JLabel jLabelTelCon1;
    private javax.swing.JLabel jLabelTelCon2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane14;
    private javax.swing.JScrollPane jScrollPane15;
    private javax.swing.JScrollPane jScrollPane16;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTableContratos;
    private javax.swing.JTable jTableContratos1;
    private javax.swing.JTable jTableContratosEstados;
    private javax.swing.JTable jTableDetalle;
    private javax.swing.JTable jTableDetallesConsulta;
    private javax.swing.JTable jTableDetallesConsulta1;
    private javax.swing.JTable jTableDetallesConsultaEstado;
    private javax.swing.JTextArea jTextAreaObserv;
    private javax.swing.JTextArea jTextAreaObserv1;
    private javax.swing.JTextArea jTextAreaObservaciones;
    private javax.swing.JTextArea jTextAreaObservacionesEstados;
    private javax.swing.JTextField jTextFielCuit1;
    private javax.swing.JTextField jTextFieldCantidad;
    private javax.swing.JTextField jTextFieldCantidadAlta;
    private javax.swing.JTextField jTextFieldCuartel;
    private javax.swing.JTextField jTextFieldUsuario3;
    private javax.swing.JTextField jTextFieldapellido;
    private javax.swing.JTextField jTextFieldclasiflistar;
    private javax.swing.JTextField jTextFieldcuartel;
    private javax.swing.JTextField jTextFielddescripcionlistar;
    private javax.swing.JTextField jTextFieldnombre;
    private javax.swing.JTextField jTextFielpreciolistar;
    private java.util.List<Entidades.Proveedor> proveedorList;
    private javax.persistence.Query proveedorQuery;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    private boolean verificar(String cuit) {
        boolean ver = false;

        if (cuit.equals("")) {
            JOptionPane.showMessageDialog(this, "Por favor ingrese el cuil del operario!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneNumerosYGuiones(cuit)) {
            JOptionPane.showMessageDialog(this, "Cuil incorrecto: Ingrese números y guiones para cuil!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!repetidoProveedor(cuit) == true) {
            JOptionPane.showMessageDialog(this, "Error el numero de cuil pertenece a otro operario !!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            ver = true;
        }

        return ver;
    }

    private boolean repetidoProveedor(String cuit) {
        boolean estarepetido = false;
        Proveedor prove = new Proveedor();
        try {
            prove = controladorprovee.buscarProveedorCuit(cuit);
            estarepetido = false;
            System.out.println("Encontró el cuil en un proveedor");
        } catch (Exception e) {
            System.out.println("NO está repetido el cuil en otro proveedor");
            estarepetido = true;
        }
        return estarepetido;
    }

    private boolean verificar(String cantidad, int cuartel, String pro) {
        boolean ver = false;
        String cuart = String.valueOf(cuartel);

        if (cantidad.equals("") || cuart.equals("") || pro.equals("")) {
            JOptionPane.showMessageDialog(this, "Por favor ingrese la cantidad de producto!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneNumerosYPuntos(cantidad)) {
            JOptionPane.showMessageDialog(this, "Cantidad incorrecta: Ingrese solo números para cantidad del producto!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneNumeros1(cuartel)) {
            JOptionPane.showMessageDialog(this, "Cuartel incorrecto: Ingrese solo números para cuartel!!!", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            ver = true;
        }
        return ver;
    }

    private boolean verificarModificacion(Float cantidad, int cuartel, Estadocontrato estado) {
        boolean ver = false;

        if (cantidad == 0 || cuartel == 0 || estado.equals("")) {
            JOptionPane.showMessageDialog(this, "Error en los datos, verifique que todos los campos estan completos", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneNumerosYPuntos1(cantidad)) {
            JOptionPane.showMessageDialog(this, "Cantidad incorrecta: Ingrese solo números", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (!validador.getInstance().soloContieneNumeros1(cuartel)) {
            JOptionPane.showMessageDialog(this, "Cuartel incorrecto: Ingrese solo números", "Error", JOptionPane.ERROR_MESSAGE);

        } else {
            ver = true;
        }
        return ver;
    }

    private void cargarComboNomProducto() {
        try {
            lista = controladorproducto.buscarTodosProducto();
            System.out.println("tamaño de la lista de Producto " + lista.size());
        } catch (Exception e) {
        }
        jComboBoxNombreProd.removeAllItems();
        for (int i = 0; i < lista.size(); i++) {
            Vector fila = new Vector();
            Producto prod = (Producto) lista.get(i);
            fila.add(prod.getNombreProducto());
            jComboBoxNombreProd.addItem(fila.get(0));
        }
        System.out.println("despues  de cargar combo nombre producto");
    }

    private void cargarTablaDetalles(Collection<Detallecontrato> detallecontratoCollection) {
        String[] encabezados = new String[5];
        encabezados[0] = "Producto";
        encabezados[1] = "Clasificacion";
        encabezados[2] = "Cantidad";
        encabezados[3] = "Precio";
        encabezados[4] = "Subtotal";
        tableModel = new TablaPersonalizada(encabezados);
        jTableDetallesConsulta.setModel(tableModel);

        try {
            listad = (List) detallecontratoCollection;
            System.out.println("tamaño de listad" + listad.size());

            for (int i = 0; i < listad.size(); i++) {
                Vector fila = new Vector();
                Detallecontrato detalle = (Detallecontrato) listad.get(i);
                fila.add(detalle.getProducto().getNombreProducto());
                fila.add(detalle.getProducto().getClasificacionproducto().getNombreclasificacion());
                fila.add(detalle.getCantidad());
                fila.add(detalle.getPrecio());
                fila.add(detalle.getCantidad() * detalle.getPrecio());
                tableModel.addRow(fila);
            }
        } catch (Exception e) {
        }
    }

    private void limpiarDatos() {
        jTextFieldnombre.setText("");
        jTextFielCuit1.setText("");
        jTextFieldapellido.setText("");

    }

    private void cargarComboProveedores() {
        try {
            listap = controladorprovee.buscarTodosProveedor();
            System.out.println("tamaño de la lista de proveedores " + listap.size());

        } catch (Exception e) {
        }

        for (int i = 0; i < listap.size(); i++) {
            Vector fila = new Vector();
            Proveedor prove = (Proveedor) listap.get(i);
            fila.add(prove.getRazonSocialProveedor());

        }
    }

//    private void CargarDetalleContrato() {
//        CargarTabla();
//        int fila = jTableContratos.getSelectedRow();
//        Contrato c = new Contrato();
//        Detallecontrato detc = new Detallecontrato();
//        c = (Contrato) contratoList1.get(fila);
//        System.out.println(c.getProveedor() + ": nro contrato en la list contrato");
//
//        //Contrato p=(Contrato) controladorcontrato.buscarContrato_X_proveedor(c.getProveedor().getIdProveedor());
//        List<Detallecontrato> ListaDetalle = controladordetallecontrato.buscarContratoProvPend(c.getProveedor());
//        //   el=controladorestlag.findLagar(l);
//        // System.out.println(p+": buscar contr por prov");
//        System.out.println(detc + ": detalle");
//
//
//
//        String[] encabezados = new String[5];
//        encabezados[0] = "Producto";
//        encabezados[1] = "Cantidad";
//        encabezados[2] = "Cuartel";
//        encabezados[3] = "Precio";
//        encabezados[4] = "Estado";
//
//
//        tableModel = new TablaPersonalizada(encabezados);
//        jTableDetallesConsulta.setModel(tableModel);
//
//        try {
//            //String prov=contratoList1.
//            // lista = (List) detc;
//            //System.out.println("tamaño de listao" + lista.size());
//
//            for (int i = 0; i < lista.size(); i++) {
//                Vector fila1 = new Vector();
//                Detallecontrato detallec = (Detallecontrato) ListaDetalle.get(i);
//                fila1.add(detallec.getProducto().getNombreProducto().toString());
//                fila1.add(detallec.getCantidad());
//                fila1.add(detallec.getCuartel());
//                fila1.add(detallec.getPrecio());
//                fila1.add(detallec.getEstadocontrato().getNombre().toString());
//                jTextAreaObserv.setText(c.getObservaciones());
//
//                tableModel.addRow(fila1);
//            }
//        } catch (Exception e) {
//        }
//
//    }
//    private void CargarDetalleContrato1() {
//        int fila = jTableContratos1.getSelectedRow();
//        Contrato c = new Contrato();
//        Detallecontrato detc = new Detallecontrato();
//        c = (Contrato) contratoList1.get(fila);
//        Contrato cto = controladorcontrato.buscarContrato_X_idContrato(c.getNumeroContrato());
//        System.out.println(cto.getNumeroContrato() + ": nro contrato en la list contrato");
//
//        //Contrato p=(Contrato) controladorcontrato.buscarContrato_X_proveedor(c.getProveedor().getIdProveedor());
//        List<Detallecontrato> ListaDetalle = (List<Detallecontrato>) controladordetallecontrato.buscarDetallecontrato_X_idContrato(cto.getNumeroContrato());
//
//
//        //   el=controladorestlag.findLagar(l);
//        // System.out.println(p+": buscar contr por prov");
//        System.out.println(ListaDetalle + ": detalle");
//
//
//
//        String[] encabezados = new String[5];
//        encabezados[0] = "Producto";
//        encabezados[1] = "Cantidad";
//        encabezados[2] = "Cuartel";
//        encabezados[3] = "Precio";
//        encabezados[4] = "Estado";
//
//
//        tableModel = new TablaPersonalizada(encabezados);
//        jTableDetallesConsulta1.setModel(tableModel);
//
//        try {
//            //String prov=contratoList1.
//            // lista = (List) detc;
//            //System.out.println("tamaño de listao" + lista.size());
//
//            for (int i = 0; i < ListaDetalle.size(); i++) {
//                Vector fila1 = new Vector();
//                Detallecontrato detallec = (Detallecontrato) ListaDetalle.get(i);
//                fila1.add(detallec.getProducto().getNombreProducto().toString());
//                fila1.add(detallec.getCantidad());
//                fila1.add(detallec.getCuartel());
//                fila1.add(detallec.getPrecio());
//                fila1.add(detallec.getEstadocontrato().getNombre().toString());
//                // jTextAreaObserv1.setText(c.getObservaciones());
//
//                tableModel.addRow(fila1);
//
//            }
//        } catch (Exception e) {
//        }
//
//    }
    private void modificarContrato() {
        boolean ver = false;
        int fila = jTableContratos1.getSelectedRow();
        int fila1 = jTableDetallesConsulta1.getSelectedRow();
        Contrato c = new Contrato();
        Detallecontrato detc = new Detallecontrato();
        c = listContrato.get(fila);
        detc = listaDetalle.get(fila1);

        Contrato contratoamodif = controladorcontrato.buscarContrato_X_idContrato(c.getNumeroContrato());
        System.out.println(contratoamodif + "contrato a modificar");
        Detallecontrato dtamodif = controladordetallecontrato.buscarDetallecontrato_X_idContrato(detc.getIdDetalleContrato());


        System.out.println(dtamodif + "detcontrato a modificar" + "detc listadetalle" + detc);


        if (fila < 0) {
            JOptionPane.showMessageDialog(this, "Debe seleccionar un contrato para modificar", "Modificar Lagar", JOptionPane.INFORMATION_MESSAGE);
        } else {


            Float cantidad = Float.parseFloat(jTextFieldCantidad.getText());
            int cuartel = Integer.parseInt(jTextFieldCuartel.getText());
            String nombreestado = jComboBoxEstado.getSelectedItem().toString();
            Estadocontrato estado = controladorestadocontrato.buscarEstadocontratoNombre(nombreestado);
            String obs = jTextAreaObserv1.getText();
            String fechamodif = validador.getInstance().obtenerFechaSistema();


            Proveedor p = new Proveedor();
            p = controladorprovee.buscarProveedorRazon(contratoamodif.getProveedor().getRazonSocialProveedor());

            int idc = contratoamodif.getNumeroContrato();
            int iddc = dtamodif.getIdDetalleContrato();
            if (verificarModificacion(cantidad, cuartel, estado)) {
                contratoamodif.setNumeroContrato(idc);
                contratoamodif.setObservaciones(obs);
                contratoamodif.setFechaHoraContrato(fechamodif);
                contratoamodif.setOperario(o);
                contratoamodif.setEstadocontrato(estado);
                contratoamodif.setProveedor(p);
                dtamodif.setIdDetalleContrato(iddc);
                dtamodif.setCantidad(cantidad);
                dtamodif.setCuartel(cuartel);
                dtamodif.setEstadocontrato(estado);


                try {

                    controladordetallecontrato.modificarDetallecontrato(dtamodif);
                    controladorcontrato.modificarContrato(contratoamodif);
                    //controladordetallecontrato.modificarDetallecontrato(dtamodif);
                    JOptionPane.showMessageDialog(this, "Modificación realizada", "Modificar contrato", JOptionPane.INFORMATION_MESSAGE);

                } catch (Exception e) {
                }

                JOptionPane.showMessageDialog(this, "Modificación realizada", "Modificar contrato", JOptionPane.INFORMATION_MESSAGE);

                CargarDetallePorContrato();
                limpiarcampos();
            }
        }
    }

    private void limpiarcampos() {
        jTextFieldCantidad.setText("");
        jTextFieldCuartel.setText("");
        jTextAreaObserv1.setText("");
        jDateChooserSelectorFecha1.setDate(null);
    }

    private void cargarComboEstadocontrato() {
        try {
            lista = controladorestadocontrato.buscarTodosEstadoPersona();
            //  System.out.println("tamaño de la lista de proveedores " + listap.size());
//            jButtonCrearDetalle.setEnabled(true);
        } catch (Exception e) {
        }
        jComboBoxEstado.removeAllItems();
        for (int i = 0; i < lista.size(); i++) {
            Vector fila = new Vector();
            Estadocontrato est = (Estadocontrato) lista.get(i);
            fila.add(est.getNombre());
            jComboBoxEstado.addItem(fila.get(0));
        }
    }

    private void CargarTabla1() {
        String[] encabezados = new String[4];
        encabezados[0] = "Numero";
        encabezados[1] = "Proveedor";
        encabezados[2] = "Fecha";
        encabezados[3] = "Estado";


        tableModel = new TablaPersonalizada(encabezados);
        jTableContratos1.setModel(tableModel);

        try {
            lista = controladorcontrato.buscarTodosContrato();
            System.out.println("tamaño de listao" + lista.size());

            for (int i = 0; i < lista.size(); i++) {
                Vector fila = new Vector();
                Contrato contrato = (Contrato) lista.get(i);
                fila.add(contrato.getNumeroContrato());
                fila.add(contrato.getProveedor().getRazonSocialProveedor());
                fila.add(contrato.getFechaHoraContrato());
                fila.add(contrato.getEstadocontrato().getNombre());


                tableModel.addRow(fila);
            }
        } catch (Exception e) {
        }
    }

    private void CargarContratosPorProveedor() {

        try {
            String[] encabezados = new String[3];
            encabezados[0] = "Numero";
            encabezados[1] = "Fecha";
            encabezados[2] = "Estado";
            String prov = jComboBoxprov.getSelectedItem().toString();
            Proveedor p = controladorprovee.buscarProveedorRazon(prov);
            System.out.println(p);
            listContrato = controladorcontrato.buscarContrato_X_proveedor(p);
            // System.out.println(listContrato + "listacontrato en cargar contratos por prov");
            //  Contrato c = new Contrato();
            // c = (Contrato) controladorcontrato.buscarTodosContrato();
            tableModel = new TablaPersonalizada(encabezados);
            jTableContratos1.setModel(tableModel);
            //  if(listContrato.contains(c.getProveedor().getRazonSocialProveedor().equals(prov))
            try {
                for (int i = 0; i < listContrato.size(); i++) {
                    Vector fila = new Vector();
                    Contrato contrato = (Contrato) listContrato.get(i);
                    System.out.println(contrato);
                    fila.add(contrato.getNumeroContrato());
                    fila.add(contrato.getFechaHoraContrato());
                    fila.add(contrato.getEstadocontrato().getNombre());
                    tableModel.addRow(fila);
                }

            } catch (Exception e) {
            }
        } catch (Exception ex) {
            Logger.getLogger(ABMContrato.class.getName()).log(Level.SEVERE, null, ex);
        }


    }

    private void CargarContratosPorProveedor1() {

        try {
            String[] encabezados = new String[3];
            encabezados[0] = "Numero";
            encabezados[1] = "Fecha";
            encabezados[2] = "Estado";
            String prov = jComboBoxprov2.getSelectedItem().toString();
            if (prov.equalsIgnoreCase("todos")) {
                CargarTabla();
            } else {
                Proveedor p = controladorprovee.buscarProveedorRazon(prov);
                System.out.println(p);
                listContrato = controladorcontrato.buscarContrato_X_proveedor(p);
                // System.out.println(listContrato + "listacontrato en cargar contratos por prov");
                //  Contrato c = new Contrato();
                // c = (Contrato) controladorcontrato.buscarTodosContrato();
                tableModel = new TablaPersonalizada(encabezados);
                jTableContratos.setModel(tableModel);
                //  if(listContrato.contains(c.getProveedor().getRazonSocialProveedor().equals(prov))
                try {
                    for (int i = 0; i < listContrato.size(); i++) {
                        Vector fila = new Vector();
                        Contrato contrato = (Contrato) listContrato.get(i);
                        System.out.println(contrato);
                        fila.add(contrato.getNumeroContrato());
                        fila.add(contrato.getFechaHoraContrato());
                        fila.add(contrato.getEstadocontrato().getNombre());
                        tableModel.addRow(fila);
                    }

                } catch (Exception e) {
                }
            }
        } catch (Exception ex) {
            Logger.getLogger(ABMContrato.class.getName()).log(Level.SEVERE, null, ex);
        }
        limpiarTabla();






    }

    private void CargarDetallePorContrato() {

        try {
            String[] encabezados = new String[5];
            encabezados[0] = "Producto";
            encabezados[1] = "Cantidad";
            encabezados[2] = "Cuartel";
            encabezados[3] = "Precio";
            encabezados[4] = "Estado";


            tableModel = new TablaPersonalizada(encabezados);
            jTableDetallesConsulta1.setModel(tableModel);
            int fila = jTableContratos1.getSelectedRow();


            Contrato c = new Contrato();
            c = (Contrato) listContrato.get(fila);
            //   int idc =  contratoList2.get(fila).getNumeroContrato();
            //     System.out.println(fila + "fila"+"idc"+idc+"c"+c+"comp"+comp);
            c = controladorcontrato.buscarContrato_X_idContrato(c.getNumeroContrato());




            //  List<Contrato> cto =  controladorcontrato.buscarContrato_X_proveedor(p);

            listaDetalle = controladordetallecontrato.buscarDetallePorContrato(c);

            System.out.println(listaDetalle + "ListaDetalle");
            //  Contrato c = new Contrato();
            // c = (Contrato) controladorcontrato.buscarTodosContrato();

            //  if(listContrato.contains(c.getProveedor().getRazonSocialProveedor().equals(prov))
            try {
                for (int i = 0; i < listaDetalle.size(); i++) {
                    Vector fila1 = new Vector();
                    Detallecontrato dc = (Detallecontrato) listaDetalle.get(i);
                    System.out.println(dc);
                    fila1.add(dc.getProducto().getNombreProducto().toString());
                    fila1.add(dc.getCantidad());
                    fila1.add(dc.getCuartel());
                    fila1.add(dc.getPrecio());
                    fila1.add(dc.getEstadocontrato().getNombre().toString());
                    tableModel.addRow(fila1);
                }

            } catch (Exception e) {
            }
        } catch (Exception ex) {
            Logger.getLogger(ABMContrato.class.getName()).log(Level.SEVERE, null, ex);
        }


    }

    private void refrescarTablaDetalle() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private void CargarDetallePorContrato1() {

        try {
            String[] encabezados = new String[5];
            encabezados[0] = "Producto";
            encabezados[1] = "Cantidad";
            encabezados[2] = "Cuartel";
            encabezados[3] = "Precio";
            encabezados[4] = "Estado";


            tableModel = new TablaPersonalizada(encabezados);
            jTableDetallesConsulta.setModel(tableModel);
            int fila = jTableContratos.getSelectedRow();


            Contrato c = new Contrato();
            c = (Contrato) listContrato.get(fila);
            //   int idc =  contratoList2.get(fila).getNumeroContrato();
            //     System.out.println(fila + "fila"+"idc"+idc+"c"+c+"comp"+comp);
            c = controladorcontrato.buscarContrato_X_idContrato(c.getNumeroContrato());




            //  List<Contrato> cto =  controladorcontrato.buscarContrato_X_proveedor(p);

            listaDetalles = controladordetallecontrato.buscarDetallePorContrato(c);

            System.out.println(listaDetalles + "ListaDetalle");
            //  Contrato c = new Contrato();
            // c = (Contrato) controladorcontrato.buscarTodosContrato();

            //  if(listContrato.contains(c.getProveedor().getRazonSocialProveedor().equals(prov))
            try {
                for (int i = 0; i < listaDetalles.size(); i++) {
                    Vector fila1 = new Vector();
                    Detallecontrato dc = (Detallecontrato) listaDetalles.get(i);
                    System.out.println(dc);
                    fila1.add(dc.getProducto().getNombreProducto().toString());
                    fila1.add(dc.getCantidad());
                    fila1.add(dc.getCuartel());
                    fila1.add(dc.getPrecio());
                    fila1.add(dc.getEstadocontrato().getNombre().toString());
                    jTextAreaObserv.setText(dc.getContrato().getObservaciones());
                    tableModel.addRow(fila1);
                }

            } catch (Exception e) {
            }
        } catch (Exception ex) {
            Logger.getLogger(ABMContrato.class.getName()).log(Level.SEVERE, null, ex);
        }


    }

    private void cargarComboRazon2() {

        Proveedor provTodos = new Proveedor();
        provTodos.setRazonSocialProveedor("Todos");
        try {
            listap = controladorprovee.buscarTodosProveedor();
            System.out.println("tamaño de la lista de proveedores " + listap.size());


            listap.add(provTodos);//.setRazonSocialProveedor("Todos"));
        } catch (Exception e) {
        }
        jComboBoxprov2.removeAllItems();
        for (int i = 0; i < listap.size(); i++) {
            Vector fila = new Vector();
            Proveedor prove = (Proveedor) listap.get(i);
            fila.add(prove.getRazonSocialProveedor());
            jComboBoxprov2.addItem(fila.get(0));
        }
    }

    private void CargarContratosPorEstados() {
        try {
            String[] encabezados = new String[4];
            encabezados[0] = "Numero";
            encabezados[1] = "Fecha";
            encabezados[2] = "Operario";
            encabezados[3] = "Proveedor";
            String ec = jComboBoxestadocontrato.getSelectedItem().toString();
            Estadocontrato estadoc = controladorestadocontrato.buscarEstadocontratoNombre(ec);
            System.out.println(estadoc);
            listContratoe = controladorcontrato.buscarContratoPorEstado(estadoc);
            if (listContratoe.size() == 0) {

                JOptionPane.showMessageDialog(this, "No encontro el estado solicitado", "Contratos por Estado", JOptionPane.INFORMATION_MESSAGE);
            }
            //  Contrato c = new Contrato();
            // c = (Contrato) controladorcontrato.buscarTodosContrato();
            tableModel = new TablaPersonalizada(encabezados);
            jTableContratosEstados.setModel(tableModel);
            //  if(listContrato.contains(c.getProveedor().getRazonSocialProveedor().equals(prov))
            try {
                for (int i = 0; i < listContratoe.size(); i++) {
                    Vector fila = new Vector();
                    Contrato contrato = (Contrato) listContratoe.get(i);
                    System.out.println(contrato);
                    fila.add(contrato.getNumeroContrato());
                    fila.add(contrato.getFechaHoraContrato());
                    fila.add(contrato.getOperario().getApellido());
                    fila.add(contrato.getProveedor().getRazonSocialProveedor());
                    tableModel.addRow(fila);
                }

            } catch (Exception e) {
            }
        } catch (Exception ex) {
            Logger.getLogger(ABMContrato.class.getName()).log(Level.SEVERE, null, ex);
        }



    }

    private void CargarDetallePorContratoEstado() {
        try {
            String[] encabezados = new String[6];
            encabezados[0] = "Producto";
            encabezados[1] = "Cantidad";
            encabezados[2] = "Cuartel";
            encabezados[3] = "Precio";
            encabezados[4] = "Estado";
            encabezados[5] = "Cantidad Recibida";


            tableModel = new TablaPersonalizada(encabezados);
            jTableDetallesConsultaEstado.setModel(tableModel);
            int fila = jTableContratosEstados.getSelectedRow();


            Contrato c = new Contrato();
            c = (Contrato) listContratoe.get(fila);
            //   int idc =  contratoList2.get(fila).getNumeroContrato();
            //     System.out.println(fila + "fila"+"idc"+idc+"c"+c+"comp"+comp);
            c = controladorcontrato.buscarContrato_X_idContrato(c.getNumeroContrato());





            //  List<Contrato> cto =  controladorcontrato.buscarContrato_X_proveedor(p);

            ListaDetalle = controladordetallecontrato.buscarDetallePorContrato(c);

            System.out.println(ListaDetalle + "ListaDetalle");
            //  Contrato c = new Contrato();
            // c = (Contrato) controladorcontrato.buscarTodosContrato();

            //  if(listContrato.contains(c.getProveedor().getRazonSocialProveedor().equals(prov))
            try {
                for (int i = 0; i < ListaDetalle.size(); i++) {
                    Vector fila1 = new Vector();
                    Detallecontrato dc = (Detallecontrato) ListaDetalle.get(i);
                    System.out.println(dc);
                    fila1.add(dc.getProducto().getNombreProducto().toString());
                    fila1.add(dc.getCantidad());
                    fila1.add(dc.getCuartel());
                    fila1.add(dc.getPrecio());
                    fila1.add(dc.getEstadocontrato().getNombre().toString());
                    fila1.add(ac.calcularCantidadPendiente(dc));
                    jTextAreaObservacionesEstados.setText(dc.getContrato().getObservaciones());
                    tableModel.addRow(fila1);
                }

            } catch (Exception e) {
            }
        } catch (Exception ex) {
            Logger.getLogger(ABMContrato.class.getName()).log(Level.SEVERE, null, ex);
        }


    }

    private void limpiarAlta() {
        jTextFieldapellido.setText("");
        jTextFieldnombre.setText("");
        jTextFieldclasiflistar.setText("");
        jTextFielCuit1.setText("");
        jTextAreaObservaciones.setText("");
        jTextFielddescripcionlistar.setText("");
        jTextFielpreciolistar.setText("");
        jTextFieldCuartel.setText("");
        jTextFieldCantidadAlta.setText("");
        String[] encabezados = new String[5];

        encabezados[0] = "Producto";
        encabezados[1] = "Clasificación";
        encabezados[2] = "Cantidad";
        encabezados[3] = "Precio";
        encabezados[4] = "SubTotal";


        tableModel = new TablaPersonalizada(encabezados);
        jTableDetalle.setModel(tableModel);
    }

    private void limpiarTabla() {
        String[] encabezados = new String[5];
        encabezados[0] = "Producto";
        encabezados[1] = "Clasificacion";
        encabezados[2] = "Cantidad";
        encabezados[3] = "Precio";
        encabezados[4] = "Subtotal";
        tableModel = new TablaPersonalizada(encabezados);
        jTableDetallesConsulta.setModel(tableModel);
    }

    private void crearReportes(String string,String detalleContrato, String cantidad) {
          Connection conn = null;






//            for (Iterator it = listad.iterator(); it.hasNext();) {
 //               Detallecontrato object = (Detallecontrato) it.next();
           try {

           //   String patenteTransporte= transporte.getPatenteTransporte();
        //    System.out.println(patenteTransporte);
            HashMap parameter = new HashMap();
            parameter.put("cantidadRecibida",detalleContrato);
            parameter.put("detalleContrato",cantidad);

            InputStream fix = this.getClass().getClassLoader().getResourceAsStream(string);
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3307/pesaje", "root", "root");
            JasperPrint print = JasperFillManager.fillReport(fix, parameter, conn);
            JasperViewer jv = new JasperViewer(print, false);
            jv.setVisible(true);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (Exception e) {
                }
            }
        }
    }



}
